No worries.
Just remember to error check the returns from fopen(), calloc(), and fread()... In paticular you need to watch for any difference between the file size by ftell() and the returned byte count from fread() to make sure you've got the entire file.
One other thing... (forgot to mention this the first time) when you call calloc() to reserve memory, if you are using string functions on it, take a few extra bytes so you are sure the file buffer is NULL terminated.
Code:
char *LoadFile(char * Filename)
{ FILE *file; // file handle
int fsize; // size of the file (good for 2 gigs)
char *buffer; // file data
file = fopen(Filename,"rb");
if (!file)
return NULL;
fseek(file, 0, SEEK_END);
fsize = ftell(file);
fseek(file, 0, SEEK_SET);
buffer = calloc(fsize + 8, 1);
if (!buffer)
{ fclose(file);
return NULL; }
fsize -= fread(buffer, 1, fsize, file);
if (fsize)
{fclose[file];
return NULL; }
fclose(file);
return buffer; }
And... don't forget to free() the buffer when you're done with it.